// @ts-ignore
import {ILayout} from '@/types/store/layout'
import {ActionContext} from 'vuex'

const state: ILayout = {
    isCollapse: false,
    // 用户信息
    userInfo: {
        name: '',
        role: []
    },
    token: {ACCESS_TOKEN: '111'},
    setting: {
        theme: 123,
        showTags: true,
        color: {
            primary: 'string',
        },
        usePinyinSearch: true
    },
    isLoading: true
}
const mutations = {
    SET_IS_COLLAPSE(state: ILayout, isCollapse: boolean) {
        console.log(isCollapse)
        state.isCollapse = isCollapse;
    },
    removeAllTagNav(state: ILayout): void {
    },
    // 添加缓存页面
    addCachedViews(state: ILayout, obj: { name: string, noCache: boolean }): void {

    },
    // 删除缓存页面
    removeCachedViews(state: ILayout, obj: { name: string, index: number }): void {

    },
}

const actions = {
    async login(context: ActionContext<ILayout, any>, param: any): Promise<void> {
        context.commit('SET_IS_COLLAPSE', param)
    },
}

const layoutState = {
    namespaced: true,
    state,
    mutations,
    actions
}

export default layoutState
